<template>
	<view class="mainpadding">
		<view class="flexleft">
			<view class="line"></view>
			<view class="titletext bold hei_text margin_left1">基本资料</view>
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top">
			<view class="ershib" style="min-width: 200rpx;">性别</view>
			<u-radio-group v-model="gender" placement="row" circle>
				<u-radio activeColor="#3478F5" :customStyle="{marginRight: '30rpx'}" label="男" name="1"></u-radio>
				<u-radio activeColor="#3478F5" label="女" name="2"></u-radio>
			</u-radio-group>
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top" @click="messageTime.timeShow=true">
			<view class="ershib" style="min-width: 200rpx;">出生年月</view>
			<view class="flexright">
				<input class="inputs " type="text" style="text-align: right;" placeholder="请选择" disabled
					v-model="birthday">
				<u-icon name="arrow-right" size="16" color="#333"></u-icon>
			</view>
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top" @click="pickerdzshow=true">
			<view class="ershib" style="min-width: 200rpx;">当前居住城市</view>
			<view class="flexright">
				<input class="inputs " type="text" style="text-align: right;" placeholder="请选择" disabled
					v-model="city_text">
				<u-icon name="arrow-right" size="16" color="#333"></u-icon>
			</view>
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top" @click="zyshow=true">
			<view class="ershib" style="min-width: 200rpx;">职业</view>
			<view class="flexright">
				<input class="inputs " type="text" style="text-align: right;" placeholder="请选择" disabled
					v-model="zy_text">
				<u-icon name="arrow-right" size="16" color="#333"></u-icon>
			</view>
		</view>
		<view class="flexleft margin_top">
			<view class="line"></view>
			<view class="titletext bold hei_text margin_left1">补充资料</view>
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top" @click="xlshow=true">
			<view class="ershib" style="min-width: 200rpx;">学历</view>
			<view class="flexright">
				<input class="inputs " type="text" style="text-align: right;" placeholder="请选择" disabled
					v-model="xl_text">
				<u-icon name="arrow-right" size="16" color="#333"></u-icon>
			</view>
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top">
			<view class="ershib" style="min-width: 200rpx;">婚姻状况</view>
			<u-radio-group v-model="hyzk" placement="row" circle>
				<u-radio activeColor="#3478F5" :customStyle="{marginRight: '30rpx'}" label="未婚" name="1"></u-radio>
				<u-radio activeColor="#3478F5" label="已婚" name="2"></u-radio>
			</u-radio-group>
		</view>

		<view class="flexbetween mainpadding ffffff radius margin_top" @click="hyshow=true">
			<view class="ershib" style="min-width: 200rpx;">行业</view>
			<view class="flexright">
				<input class="inputs " type="text" style="text-align: right;" placeholder="请选择" disabled
					v-model="hy_text">
				<u-icon name="arrow-right" size="16" color="#333"></u-icon>
			</view>
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top" @click="gznxshow = true">
			<view class="ershib" style="min-width: 200rpx;">工作年限</view>
			<view class="flexright">
				<input class="inputs " type="text" style="text-align: right;" placeholder="请选择" disabled
					v-model="gznx_text">
				<u-icon name="arrow-right" size="16" color="#333"></u-icon>
			</view>
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top" @click="grysrshow = true">
			<view class="ershib" style="min-width: 200rpx;">个人月收入</view>
			<view class="flexright">
				<input class="inputs " type="text" style="text-align: right;" placeholder="请选择" disabled
					v-model="grysr_text">
				<u-icon name="arrow-right" size="16" color="#333"></u-icon>
			</view>
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top" @click="jtysrshow = true">
			<view class="ershib" style="min-width: 200rpx;">家庭月收入</view>
			<view class="flexright">
				<input class="inputs " type="text" style="text-align: right;" placeholder="请选择" disabled
					v-model="jtysr_text">
				<u-icon name="arrow-right" size="16" color="#333"></u-icon>
			</view>
		</view>
		<view class="flexbetween mainpadding ffffff radius margin_top">
			<view class="ershib" style="min-width: 200rpx;">有无小孩</view>
			<u-radio-group v-model="has_child" placement="row" circle>
				<u-radio activeColor="#3478F5" :customStyle="{marginRight: '30rpx'}" label="有" name="1"></u-radio>
				<u-radio activeColor="#3478F5" label="无" name="2"></u-radio>
			</u-radio-group>
		</view>
		<view class="submitbtn margin_top6" @click="submit">确定</view>
		<timePicker :messageTime="messageTime" @timeConfirm="timeConfirm"></timePicker>
		<pickercity :messageInfo="{pickerdzshow:pickerdzshow}" @surecity="surecity"></pickercity>
		<u-picker :show="zyshow" title="职业" keyName="name" :columns="zy_columns" @confirm="zyConfirm"
			@cancel="zyshow=false"></u-picker>
		<u-picker :show="xlshow" title="学历" keyName="name" :columns="xl_columns" @confirm="xlConfirm"
			@cancel="xlshow=false"></u-picker>
		<u-picker :show="hyshow" title="行业" keyName="name" :columns="hy_columns" @confirm="hyConfirm"
			@cancel="hyshow=false"></u-picker>
		<u-picker :show="gznxshow" title="工作年限" keyName="name" :columns="gznx_columns" @confirm="gznxConfirm"
			@cancel="gznxshow=false"></u-picker>
		<u-picker :show="grysrshow" title="个人月收入" keyName="name" :columns="grysr_columns" @confirm="grysrConfirm"
			@cancel="grysrshow=false"></u-picker>
		<u-picker :show="jtysrshow" title="家庭月收入" keyName="name" :columns="jtysr_columns" @confirm="jtysrConfirm"
			@cancel="jtysrshow=false"></u-picker>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				messageTime: {
					timeShow: false,
					title: "选择出生年月",
					mode: "date" //date日期，datetime年月日时分秒，time时间
				},
				pickerdzshow: false,
				cityinfo: {},
				city_text: "",
				gender: "1",
				birthday: "",
				province_id: "",
				city_id: "",
				zy_id: "", //职业
				zyshow: false,
				zy_text: "",
				zy_columns: [],
				xl_id: "", //学历
				xlshow: false,
				xl_text: "",
				xl_columns: [],
				hyzk: "1", //婚姻状况
				hy_id: "", //行业
				hyshow: false,
				hy_text: "",
				hy_columns: [],
				gznx_id: "", //工作年限
				gznxshow: false,
				gznx_text: "",
				gznx_columns: [],
				grysr_id: "", //个人月收入
				grysrshow: false,
				grysr_text: "",
				grysr_columns: [],
				jtysr_id: "", //家庭月收入
				jtysrshow: false,
				jtysr_text: "",
				jtysr_columns: [],
				has_child: "1", //有无小孩
			}
		},
		onLoad() {
			this.getzy()
			this.getxl()
			this.gethy()
			this.getgznx()
			this.getgrysr()
			this.getjtysr()
			this.init()
		},
		methods: {
			init() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					let data = res.data
					this.birthday = data.birthday
					this.gender = data.gender.toString()
					this.province_id = data.province_id
					this.city_id = data.city_id
					this.city_text = data.cityinfo == "/" ? '' : data.cityinfo
					this.has_child = data.has_child.toString()
					this.hyzk = data.hyzk.toString()
					this.zy_id = data.zy_id //职业
					this.zy_text = data.zy ? data.zy.name : "" //职业
					this.xl_id = data.xl_id //学历
					this.xl_text = data.xl ? data.xl.name : "" //学历
					this.hy_id = data.hy_id //行业
					this.hy_text = data.hy ? data.hy.name : "" //行业
					this.gznx_id = data.gznx_id //工作年限
					this.gznx_text = data.gznx ? data.gznx.name : "" //工作年限
					this.grysr_id = data.grysr_id //个人月收入
					this.grysr_text = data.grysr ? data.grysr.name : ""
					this.jtysr_id = data.jtysr_id //家庭月收入
					this.jtysr_text = data.jtysr ? data.jtysr.name : ""
				})
			},
			submit() {
				if (this.birthday == "") {
					httpRequest.toast("请选择出生日期");
					return false;
				}
				if (this.city_text == "") {
					httpRequest.toast("请选择当前居住城市");
					return false;
				}
				if (this.zy_id == "") {
					httpRequest.toast("请选择职业");
					return false;
				}

				httpRequest.request('/api/user/profilezl', 'GET', {
					gender: this.gender,
					birthday: this.birthday,
					province_id: this.province_id,
					city_id: this.city_id,
					zy_id: this.zy_id,
					xl_id: this.xl_id,
					hyzk: this.hyzk,
					hy_id: this.hy_id,
					gznx_id: this.gznx_id,
					grysr_id: this.grysr_id,
					jtysr_id: this.jtysr_id,
					has_child: this.has_child,
				}).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						setTimeout(() => {
							uni.navigateBack(1)
						}, 1000)
					}
				})
			},
			getzy() { // 职业
				httpRequest.request('/api/user/zyIndex', 'GET', {}).then(res => {
					this.zy_columns.push(res.data)
				})
			},
			zyConfirm(e) {
				this.zy_id = e.value[0].id
				this.zy_text = e.value[0].name
				this.zyshow = false
			},
			getxl() { // 学历
				httpRequest.request('/api/user/xlIndex', 'GET', {}).then(res => {
					this.xl_columns.push(res.data)
				})
			},
			xlConfirm(e) {
				this.xl_id = e.value[0].id
				this.xl_text = e.value[0].name
				this.xlshow = false
			},
			gethy() { // 行业
				httpRequest.request('/api/user/hyIndex', 'GET', {}).then(res => {
					this.hy_columns.push(res.data)
				})
			},
			hyConfirm(e) {
				this.hy_id = e.value[0].id
				this.hy_text = e.value[0].name
				this.hyshow = false
			},
			getgznx() { // 工作年限
				httpRequest.request('/api/user/gznxIndex', 'GET', {}).then(res => {
					this.gznx_columns.push(res.data)
				})
			},
			gznxConfirm(e) {
				this.gznx_id = e.value[0].id
				this.gznx_text = e.value[0].name
				this.gznxshow = false
			},
			getgrysr() { // 个人月收入
				httpRequest.request('/api/user/grysrIndex', 'GET', {}).then(res => {
					this.grysr_columns.push(res.data)
				})
			},
			grysrConfirm(e) {
				this.grysr_id = e.value[0].id
				this.grysr_text = e.value[0].name
				this.grysrshow = false
			},
			getjtysr() { // 家庭月收入
				httpRequest.request('/api/user/jtysrIndex', 'GET', {}).then(res => {
					this.jtysr_columns.push(res.data)
				})
			},
			jtysrConfirm(e) {
				this.jtysr_id = e.value[0].id
				this.jtysr_text = e.value[0].name
				this.jtysrshow = false
			},

			timeConfirm(e) {
				this.birthday = e
			},
			surecity(e) { //选择城市
				this.pickerdzshow = false
				if (e) {
					this.province_id = e.provenceid
					this.city_id = e.cityid
					this.city_text = e.provence + "/" + e.city
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	/deep/.u-radio-group {
		flex: none !important;
	}
</style>